#define ElemType int

typedef struct ListNode List_Node;

#include "common.h"

bool backspaceCompare(char* s, char* t);

int main()
{
	return 0;
}

bool backspaceCompare(char* s, char* t)
{
	int skip_s = 0, skip_t = 0;
	for (int ptr_s = strlen(s) - 1, ptr_t = strlen(t) - 1; ptr_s >= 0 || ptr_t >= 0; ptr_s--, ptr_t--) {
		while (ptr_s >= 0)
			if (s[ptr_s] == '#')
				skip_s++, ptr_s--;
			else if (skip_s > 0)
				skip_s--, ptr_s--;
			else
				break;

		while (ptr_t >= 0)
			if (t[ptr_t] == '#')
				skip_t++, ptr_t--;
			else if (skip_t > 0)
				skip_t--, ptr_t--;
			else
				break;

		if (ptr_s >= 0 && ptr_t >= 0) {
			if (s[ptr_s] != t[ptr_t])
				return false;
		} else if (ptr_s >= 0 || ptr_t >= 0)
			return false;
	}
	return true;
}
